<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>新开卡或卡充值提成设定管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		global.loginPassword = "${fns:getLoginPw()}";
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		$(document).ready(function() {
			$("#contentTable tbody tr").click(function(){
				sessionStorage.parentPageNo = $("#pageNo").val();
				operateMenu(this.id);
			});
			var currentSelectId = '${currentSelectId}';
			if(currentSelectId){
				$("#"+currentSelectId).addClass("opreationTR");
			} else {
				$("#contentTable tbody tr:first-child").addClass("opreationTR");
			}
			addParentPageNo();
		});
		
		function addParentPageNo() {
			var pageNo = sessionStorage.bonusPageNo;
			var href = "${ctx}/employee/employee/bonusList/?pageNo=" + pageNo + "&currentSelectId=${employee.id}";
			$("#return").attr("href", href);
		}
		
		function operateMenu(id){
			var item = $("#opreation-"+ id);
			if(item.length > 0) {
				item.remove();
				this.event.stopPropagation();
				return;
			}
			$(".opreationTR").removeClass("opreationTR");
			$(".opreation").remove();
			var html= "<tr id='opreation-" + id + "' class='opreation'><td colspan='6'>";
				html += '<a data-role="button" data-inline="true" href="${ctx}/employee/storeBonusSettingCard/form?id='+ id +'">修改</a>';
				html += '<a data-role="button" data-inline="true" href="${ctx}/employee/storeBonusSettingCard/delete?id='+ id +'" onclick="return confirmx(\'确认要删除该新开卡或卡充值提成设定吗？\', this.href)">删除</a>';
				html += '</td></tr>';
			$("#" + id).after(html);
			$("#" + id).addClass("opreationTR");
			$("#contentTable").trigger("create");
			this.event.stopPropagation();
		}
		function copyConfirm() {
			var submit = function(){
				$('#dialog-copyConfirm').popup('open');
            }
    		loginPasswordPopup(submit);
		}
		function copy(ifModify) {
			window.location.href = "${ctx}/employee/storeBonusSettingCard/copy?ifModify=" + ifModify;
		}
	</script>
</head>
<body>
<div class="icon-buttons">
	<a id="return" data-role="button" data-inline="true" data-icon="back" data-iconpos="notext"  href="">返回</a>
</div>
	<nav data-role="navbar">
		<ul>
			<li><a class="ui-btn-active" href="${ctx}/employee/storeBonusSettingCard/?employeeId=${employee.id}">新开卡或卡充值提成设定</a></li>
			<li><a href="${ctx}/employee/storeBonusSettingProduct/?employeeId=${employee.id}&type=0">产品提成设定</a></li>
			<li><a href="${ctx}/employee/storeBonusSettingCare/?employeeId=${employee.id}&type=0">护理提成设定</a></li>
		</ul>
	</nav>
	<form:form id="searchForm" modelAttribute="storeBonusSettingCard" action="${ctx}/employee/storeBonusSettingCard/?employeeId=${employee.id}" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<a data-role="button" data-inline="true" href="${ctx}/employee/storeBonusSettingCard/add">新增模板设定</a>
		<input type="button" value="复制模板设定" data-inline="true" onclick="copyConfirm()">
	</form:form>
	<tags:message content="${message}"/>
	<table id="contentTable" data-role="table" class="ui-responsive table-stroke">
		<thead><tr><th>会员卡类别</th><th>卡名</th><th>提成方式</th><th>提成比例</th><th>提成金额</th></tr></thead>
		<tbody>
		<c:forEach items="${page.list}" var="storeBonusSettingCard">
			<tr id="${storeBonusSettingCard.id}">
				<td>${fns:getDictLabel(storeBonusSettingCard.card_template_type, "card_type","")}</td>
				<c:set var="key" value="${storeBonusSettingCard.card_template_type}-${storeBonusSettingCard.card_template_id}"/> 
				<td>${cardNameMap[key]}</td>
				<td>${fns:getDictLabel(storeBonusSettingCard.bonus_type, "bonus_type", "")}</td>
				<td>${fns:changeDisCount(storeBonusSettingCard.bonus_rate)}%</td>
				<td>${storeBonusSettingCard.fixed_money}元</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	
	<div data-role="popup" id="dialog-copyConfirm" data-overlay-theme="a" data-theme="c" data-dismissible="false" class="ui-corner-all">
    <div data-role="header" data-theme="a" class="ui-corner-top">
        <h1>温馨提示</h1>
    </div>
    <div data-role="content" style="width:430px" data-theme="d" class="ui-corner-bottom ui-content">
        <h3 class="ui-title">此操作将会使用提成设定模板里的设定数据，是否需要覆盖已有设定，或者只追加数据？</h3>
        <br />
    </div>
    <div data-theme="a" data-role="footer">
	    <fieldset data-role="controlgroup" data-type="horizontal" data-inline="true">
    		<button data-inline="true" onclick="copy(1)">覆盖</button>
    		<button data-inline="true" onclick="copy(0)">追加</button>
        	<a href="#" data-role="button" data-inline="true"  data-rel="back" data-theme="a">取消</a>
    	</fieldset>
    </div>
</div>
</body>
</html>
